class AuthenticationManager(object):

    def __init__(self, timeToLive):
        """
        :type timeToLive: int
        """
        self.delay = timeToLive
        self.d = {}

    def generate(self, tokenId, currentTime):
        """
        :type tokenId: str
        :type currentTime: int
        :rtype: None
        """
        self.d[tokenId] = currentTime + self.delay



    def renew(self, tokenId, currentTime):
        """
        :type tokenId: str
        :type currentTime: int
        :rtype: None
        """
        if tokenId in self.d and self.d[tokenId] > currentTime:
            self.d[tokenId] = currentTime + self.delay


    def countUnexpiredTokens(self, currentTime):
        """
        :type currentTime: int
        :rtype: int
        """
        ans = 0
        for key in self.d:
            if self.d[key] > currentTime:
                ans += 1
        return ans